package com.xmu.makerspace.domain;

import javax.persistence.*;

/**
 * Created by status200 on 2017/9/1.
 */
@Entity
@IdClass(SeatPK.class)
public class Seat {
    private Integer roomNo;
    private Integer seatNo;
    private String studentId;

    @Id
    @Column(name = "room_no", nullable = false)
    public Integer getRoomNo() {
        return roomNo;
    }

    public void setRoomNo(Integer roomNo) {
        this.roomNo = roomNo;
    }

    @Id
    @Column(name = "seat_no", nullable = false)
    public Integer getSeatNo() {
        return seatNo;
    }

    public void setSeatNo(Integer seatNo) {
        this.seatNo = seatNo;
    }

    @Basic
    @Column(name = "student_id", nullable = true, length = 20)
    public String getStudentId() {
        return studentId;
    }

    public void setStudentId(String studentId) {
        this.studentId = studentId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Seat seat = (Seat) o;

        if (roomNo != null ? !roomNo.equals(seat.roomNo) : seat.roomNo != null) return false;
        if (seatNo != null ? !seatNo.equals(seat.seatNo) : seat.seatNo != null) return false;
        if (studentId != null ? !studentId.equals(seat.studentId) : seat.studentId != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = roomNo != null ? roomNo.hashCode() : 0;
        result = 31 * result + (seatNo != null ? seatNo.hashCode() : 0);
        result = 31 * result + (studentId != null ? studentId.hashCode() : 0);
        return result;
    }
}
